<?php
/** .-------------------------------------------------------------------
 * |  Software: [HDCMS framework]
 * |      Site: www.hdcms.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

namespace web\admin\controller;


class Tag extends Common{
	protected $db;
	public function __construct(){
		parent::__construct();
		$this->db = new \system\model\Tag();
	}
    //动作
	public function index(){
		$data =$this->db->getAll();
		View::with('data',$data)->make();
	}
	public function add(){
		if (IS_POST){
			if ($this->db->store()){
				message('添加成功',u('index'),'success');
			}
			message($this->db->getError(),'back','error');
		}
		View::make();
	}
//	编辑
	public function edit(){
		if (IS_POST){
			if ($this->db->edit()){
				message('修改成功',u('index'),'success');
			}
			message($this->db->getError(),'back','error');
		}
		$tid = q('get.tid',0,'intval');
		$oldData = $this->db->where('tid',$tid)->first();
		View::with('oldData',$oldData)->make();
	}
//	删除
	public function del(){
		$tid = q('get.tid',0,'intval');
		$this->db->where('tid',$tid)->delete();
		message('删除成功',u('index'),'success');
	}
}
